package com.yjt.zdjf.standard.common.init;

import java.util.Collections;
import java.util.Enumeration;
import java.util.List;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import org.apache.commons.collections.EnumerationUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ZDJFInit extends HttpServlet {

	Logger log = LoggerFactory.getLogger(ZDJFInit.class);

	/**
	 * 
	 */
	private static final long serialVersionUID = 1994360445247550240L;

	@Override
	@SuppressWarnings("rawtypes")
	public void init() throws ServletException {
		ServletContext context = this.getServletConfig().getServletContext();
		Enumeration paramNames = getInitParameterNames();
	
		List<String> lstParamNames = EnumerationUtils.toList(paramNames);
		Collections.sort(lstParamNames);
		
		String initObjName = null;
		for(String paramName : lstParamNames)
		{
			try{
				initObjName = getInitParameter(paramName);
				Init initObj = (Init) Class.forName(initObjName).newInstance();
				initObj.init(context);
			}catch(Exception e){
				log.error(initObjName + " init fail!", e);
			}
		}
	}
}